#include <iostream>
#include <cassert>
#include <vector>
#include <algorithm>
#include <sstream>
#include <list>
#include <stack>
#include <queue>
#include <map>
using namespace std;

// https://blog.csdn.net/u012028275/article/details/113793827
// https://blog.csdn.net/weixin_30670925/article/details/97838351?utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-1.control&dist_request_id=&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-1.control


//支持正数
float MagicSqrt(float x)
{
    float xhalf = 0.5f * x;
    int i = *(int*)&x;
    i = 0x1fbd1df5 + (i >> 1);
    x = *(float*)&i;
    x = 0.5f * x + xhalf / x;
    //x = 0.5f * x + xhalf / x; //两次牛顿迭代可以提高精度
    
    return x;
}


int main(){
    cout<< MagicSqrt(9)<<endl;
    return 0;
}